function u = getEigenbg(bgs)
    m = mean(bgs);
    y = bgs - ones(size(bgs,1),1) * m; % normalize background by substracting mean 
    [V,D] = eig(y * y');
    u = y' * V; 
    u = u';
    for i = 1:size(u,1)
        u(i,:) = u(i,:)./norm(u(i,:));
    end
    u = flipud(u) ;
    D = flipud(diag(D)) ;
    return